﻿
#include "ICPUtility.h"

string ICPUtility::INPUTPATH = ".\\InputF\\";
string ICPUtility::OUTPUTPATH = ".\\OutputF\\";
string ICPUtility::moduleFlag = "X";
string ICPUtility::filiale = "XX";

time_t ICPUtility::dummyBgnDate = makeTime(2020, 1, 1);
time_t ICPUtility::dummyEndDate = makeTime(1900, 1, 1);

time_t ICPUtility::bgnDate = makeTime(2019, 2, 11);
time_t ICPUtility::endDate = makeTime(2019, 2, 24);

time_t ICPUtility::bgnTime = makeTime(2019, 2, 11);
time_t ICPUtility::endTime = makeTime(2019, 2, 24, 23, 59, 59);

/* param121 */
time_t ICPUtility::signIn = 90 * 60;                        // 签入时间
time_t ICPUtility::signOut = 30 * 60;                       // 签出时间
time_t ICPUtility::drivingIn = 0;                           // 前车程时间
time_t ICPUtility::drivingOut = 0;                          // 后车程时间
time_t ICPUtility::breakInterval = 3 * HOUR_SECONED_DEFINE; // 二次进场判断标准
// 换机间隔判断标准
time_t ICPUtility::minTransferInterval = 2 * HOUR_SECONED_DEFINE;
// 最短隔日休息时间标准
time_t ICPUtility::minRestInterval = 10 * HOUR_SECONED_DEFINE;
// 2个飞行执勤期的最小间隔（跨6时区，回基地后必须安排48小时休息）
time_t ICPUtility::minRestTimeZone6 = 48 * HOUR_SECONED_DEFINE;
// 不得连续5个日历日执行任何飞行任务的限制裕度值, 默认第四天20:00
time_t ICPUtility::day5Buffer = 20 * HOUR_SECONED_DEFINE;

int ICPUtility::maxBaseCnt = 3;              // 任务环最多经过多少个基地
int ICPUtility::maxDaysInPairing = 5;        // 任务环最大天数
int ICPUtility::maxFlyDayInPairing = 4;      ////任务环航班任务最大天数
int ICPUtility::maxDeadheadNumInPairing = 2; // 单个任务环中最大置位次数
int ICPUtility::maxLayoverAirportCnt = 1;    // 单个任务环中最大过夜机场数次数
int ICPUtility::maxLegNumInDuty = 4;         // 单个任务环中最大航段数
// 单个任务最大飞行时长(非当日往返基地)
time_t ICPUtility::maxFlyTime = 10 * 3600;
// 单个任务最大飞行时长(当日往返基地)
time_t ICPUtility::maxFlyTimeClosed = 12 * 3600;
// 二次进退场休息时间小于1小时
time_t ICPUtility::timeSecondCheckInShort = 1 * HOUR_SECONED_DEFINE;
// 在外过夜休息时间不超过 48 小时（软约束）
time_t ICPUtility::timeMaxRestNonBase = 48 * HOUR_SECONED_DEFINE;
// 早晚跳判断标准
time_t ICPUtility::timeLongDay = 10 * 3600;
// 早班时间区间depTime[6:00, 9:00]
pair<time_t, time_t> ICPUtility::earlyDuty = make_pair<time_t, time_t>(6 * 3600, 9 * 3600);
// 晚班时间区间arrTime[19:00, 24:00],(00:00, 6:00]
pair<time_t, time_t> ICPUtility::lateDuty1 = make_pair<time_t, time_t>(19 * 3600, 24 * 3600);
// 晚班时间区间arrTime[19:00, 24:00],(00:00, 6:00]
pair<time_t, time_t> ICPUtility::lateDuty2 = make_pair<time_t, time_t>(0, 6 * 3600);

// 过站时间标准// 坐车与航班的最小间隔【legOut->getStd() - legOut->getSignIn()】
int ICPUtility::minTransferVbFlt = 90 * 60;
// 航班与坐车的最小间隔【航班后执行坐车置位，只要求航班和置位时间没有冲突】
int ICPUtility::minTransferFltVb = 0;
// 搭机与航班的最小间隔【】
int ICPUtility::minTransferVaFlt = 2 * HOUR_SECONED_DEFINE;
// 航班与搭机的最小间隔
int ICPUtility::minTransferFltVa = 2 * HOUR_SECONED_DEFINE;
// 航班与搭机的最小间隔
int ICPUtility::minTransferVaVa = 2 * HOUR_SECONED_DEFINE;

/* cost */
// 1航班覆盖
double ICPUtility::costCover = 10000;
// 2座机置位
double ICPUtility::costDeadheadVA = 50;
// 3坐车置位
double ICPUtility::costDeadheadVB = 50;
// 4总出勤人天数
double ICPUtility::costPerCrewPerDay = 2;
// 5早晚跳
double ICPUtility::costDutyMornEven = 0;
// 6早班
double ICPUtility::costDutyMorning = 0;
// 7晚班
double ICPUtility::costDutyEvening = 0;
// 8过夜天数
double ICPUtility::costLayoverDays = 10;
// 9二次进场成本
double ICPUtility::costBreak = 1;
// 10单日飞4段且包含二次进场
double ICPUtility::costBreakLeg4 = 0;
// 11任务环多次二次进场
double ICPUtility::costBreakMulti = 2;
// 12二次进退场休息时间小于1小时成本，每次减0.5
double ICPUtility::costBreakShort = 0;
double ICPUtility::costFreeOneDay = 3; // 13外站空休
// 14外站休息时间大于48小时成本，每次减0.5
double ICPUtility::costFreeTwoDay = 5;
// 15排班周期内的不同过夜站点的个数超过2（不含）成本
double ICPUtility::costLayoverAirport = 1;
// 16过家门而不入
double ICPUtility::costLayoverHome = 1;
// 17在非基地过夜扣分
double ICPUtility::costLayoverNonBase = 1;
// 18瘦班成本
double ICPUtility::costThinTask = 3;
// 19同日换飞机
double ICPUtility::costDutyTransfer = 2;
// 20任务环稳定性成本
double ICPUtility::costVoyageOrderly = 100;
// 24超额成本
double ICPUtility::costExcessCrew = 1000;
// 25未闭环罚分
double ICPUtility::costUnclosed = 1500;
// 26占场时间越短越好
double ICPUtility::costDP = 100;

/*profit*/
double ICPUtility::profitHisRatio = 100;     // 21历史拟合度
double ICPUtility::profitMatchPattern = 100; // 22模板匹配收益
double ICPUtility::profitRoundTrip = 1;      // 23经停航班或来回程尽量组在一起

/* init parameter */
bool ICPUtility::isExpModel = false;
double ICPUtility::gap = 1.0;
double ICPUtility::fixUbBar = 0.75;
double ICPUtility::fixLbBar = 0.01;
int ICPUtility::minBetterCols = 0;
int ICPUtility::slowImproveIter = 5;
double ICPUtility::dominateBar = 30;
DOMINATE_MODE ICPUtility::dominateMode = DOMINATE_MODE::MULTI;
RULE_OR_COST ICPUtility::baseAsMode = RULE_OR_COST::AS_RULE;

bool ICPUtility::isDebug = false;

/* 以下2个参数用来配置Pairing每天从SHA始发的外籍可飞任务环，最少需要多少个，现在参数设定为0个，等于是不起作用
 */
string ICPUtility::crmForeignAirport = "PPP";
int ICPUtility::ctmNumMinForeignPairingPerDay = 0;

vector<BasResLimit*> ICPUtility::basResLimitList;        // 基地资源约束
map<string, int> ICPUtility::mapBaseDailyCrewCnt;        // 基地机组人数约束
vector<BaseDailyCrewCnt*> ICPUtility::baseDailyCrewCntList;//基地每天已占用人数
vector<ICPPairingConfig*> ICPUtility::pairingConfigList; // 任务环定义

vector<string> ICPUtility::basBaseStrList;               // 基地字符串
set<string> ICPUtility::setRule;                         // 规则启用开关
vector<CCAR5> ICPUtility::ccar5List;                     // CCAR5运行标准
map<string, AirportConfig> ICPUtility::mapAirportConfig; // 机场进离场及前车程后车程时间
map<string, double> ICPUtility::mapBaseOverstaff;        // 基地资源紧张程度
vector<baseDirect> ICPUtility::lstBaseDirect;
map<string, double> ICPUtility::mapDutyRatio;    // 历史（默认过去两周）上FlightCom的占比
map<string, double> ICPUtility::mapLinkRatio;    // 历史（默认过去两周）Duty上航班衔接的拟合度
vector<string> ICPUtility::lstDutyVoyageZhuZhan; // 历史（默认过去两周）驻站Duty上FlightCom列表
map<string, double> ICPUtility::mapPairingVoyageMultiDay; // 历史（默认过去两周）驻站Pairing上FlightCom列表
map<string, double> ICPUtility::mapPairingRatio;          // 历史（默认过去两周）上FlightCom的占比
vector<BasPattern*> ICPUtility::lstPattern;
vector<SchConfigB*> ICPUtility::lstSchConfigB;  // 备份机组配置标准
map<string, double> ICPUtility::linkDayDualMap; // DUTY衔接的稳定性